# Maintainer (Arch): Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Douglas Soares de Andrade <dsandrade@gmail.com>
# Contributor: Michael Fellinger <m.fellinger@gmail.com>
# Maintainer : Sagar Acharya <sagar@hyperbola.info>

pkgname=sqlitebrowser
pkgver=3.12.1
pkgrel=1
pkgdesc='SQLite Database browser is a light GUI editor for SQLite databases, built on top of Qt'
url='https://sqlitebrowser.org/'
arch=('x86_64')
license=('GPL-3')
depends=('qt-base' 'hicolor-icon-theme' 'desktop-file-utils')
makedepends=('git' 'cmake' 'ninja' 'qt-tools' 'quilt')
source=("https://github.com/sqlitebrowser/sqlitebrowser/archive/refs/tags/v${pkgver}.tar.gz"
		"series"
		"0001-Use-system-qscintilla2.patch"
		"0002-Install-SVG-logo-as-hicolor-scalable-icon.patch")
sha512sums=('f0a62958008693606d9ab04b0413fa10705c7b45fb970c218d8f1adfe8ca01895a6470f369ded6cb7a9338c27385838b8d57c89b5855b4050ce9bec0d69626d1'
			'8e0691ad29141c97aee759a3d1bf26c15b53a43e4a7af99d65087d1980a7f3b6e64bd98cd7b97c371182f948d30e9b07a438888c5c7ce74d1a113c63a747fd73'
			'fbeb6397f735f0ba8ab6b4d7dcfb24213a7d6a3290d8a148a8fc403b23c592b4e689a33898d93123f4a7781b0b0ff19e8fa40908bf73406fc62ffb8e9f32e86f'
			'460b69ca47178d50f8597683ac5c51f8b6b6bc55cb0e9d87a4f686dd989464e77fd653a5ec5f68a61283b93452bccc6972a7cb6747fadb4feb640aab234d4bca')

#validpgpkeys=('05E463FDB5802C3D00257F9C79EAD0AB3BD7DD2C')
# Justin Clift (GPG key for signing git commits) <justin@postgresql.org>

prepare() {
	cd ${pkgname}-${pkgver}
	
	mkdir ./patches
  	cp ${srcdir}/series ./patches
  	cp ${srcdir}/*.patch ./patches

  	export QUILT_PATCHES=patches
  	export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  	export QUILT_DIFF_ARGS='--no-timestamps'

  	quilt push -av
}

build() {
  cd ${pkgname}-${pkgver}
  cmake -B build \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DENABLE_TESTING=ON \
    -Wno-dev \
    -G Ninja
  ninja -C build
}

check() {
  cd ${pkgname}-${pkgver}/build
  ctest -V
}

package() {
  cd ${pkgname}-${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm644 LICENSE -t $pkgdir/usr/share/licenses/$pkgname
}
